{* $Id$ *}
{include_core file="admin/lib/header.html" title="任务专题添加/编辑"}
<div class="page-header border-bottom clearfix">
    <h2 class="left">任务专题添加/编辑</h2>
    <a href='{AnUrl("topic/admin/job")}' class="btn btn-default btn-sm right">&lt;&nbsp;返回列表</a>
</div>
<div class="add-form">
    <form class="js_creatForm" action="{AnUrl('topic/admin/job/save')}" method="post">
        <table class="table" cellpadding="0" cellspacing="0">
            <tr>
                <th><label class="add-f-label">任务名称：</label></th>
                <td>
                    <input autofocus="1" class="add-f-ipt1" name="data[name]" value="{$info.name}"/>
                    <input type="hidden" name="data[id]" value="{$info.id}"/>
                    <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>请填写名称
                    </div>
                </td>
            </tr>
            <tr>
                <th><label class="add-f-label">任务起止时间：</label></th>
                <td>
                    <input readonly="readonly" type="text" class="search-f-ipt1 search-f-ipt2" name="data[start_date]"
                           value="{$info.start_date}" id="startDateUl">
                    <span class="search-f-line"></span>
                    <input readonly="readonly" type="text" class="search-f-ipt1 search-f-ipt2" name="data[end_date]"
                           value="{$info.end_date}" id="endDateUl">
                    <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>任务起止日期
                    </div>
                </td>
            </tr>
            <tr>
                <th><label class="add-f-label">任务说明：</label></th>
                <td>
                    <textarea style="height:10em;width:30em;" name="data[info]">{$info.info}</textarea>
                    <div class="tips"><span style="line-height: 34px;color: #f00;margin-right: 10px;">*</span>任务说明
                    </div>
                </td>
            </tr>
            <tr>
                <th><label class="add-f-label">作用范围：<br/>(合伙人列表)</label></th>
                <td>
                    <textarea style="height:5em;width:20em;" name="data[term_agency_ids]">{$info.term.agency_ids}</textarea>
                    <div class="tips">合伙人ID列表, 逗号分隔(或一行一个, 可混用)
                    </div>
                </td>
            </tr>
            <tr>
                <th>&nbsp;</th>
                <td class="noborder">
                    <button type="submit" class="btn btn-success js_submit">
                        &nbsp;&nbsp;&nbsp;保存&nbsp;&nbsp;&nbsp;</button>
                </td>
            </tr>
        </table>
    </form>
</div>
<script>

    $('#startDateUl, #endDateUl').datepicker({
        dateFormat: 'yy-mm-dd',
        showButtonPanel: true,
        yearRange: (new Date().getFullYear() - 1) + ':' + (new Date().getFullYear() + 1),
        changeYear: true,
        changeMonth: true,
        yearSuffix: ''
    });

    $('.js_creatForm').on('submit', function (e) {
        e.preventDefault();
        var form = $(this);
        var d = form.serializeArray();
        var data = [];
        for (var i = 0, len = d.length; i < len; i++) {
            data[d[i]['name']] = $.trim(d[i]['value']);
        }

        if (data['data[name]'] == '') {
            form.find('[name="data[name]"]').effect('highlight');
            showMsg('请填写名称');
            return;
        }

        if (data['data[start_date]'] == '') {
            form.find('[name="data[start_date]"]').effect('highlight');
            showMsg('请填写活动开始日期');
            return;
        }

        if (data['data[end_date]'] == '') {
            form.find('[name="data[end_date]"]').effect('highlight');
            showMsg('请填写活动截止日期');
            return;
        }

        if (data['data[start_date]'] > data['data[end_date]']) {
            showMsg('结束时间应大于等于开始时间');
            return;
        }

        form.get(0).submit();
    });
</script>
{include_core file="admin/lib/footer.html"}